home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
diskmags
/
3565-4.665
/
dmg-4385
/
issue_10
/
24.pne
< prev
next >
Wrap
Text File
|
1987-04-21
|
14KB
|
495 lines
You should have allready read basic tut 10/1 before attemting
this article
This is a more or less up and running version. But I have not
included any tests to see if the jigsaw is completed or not.
Lesson 5
10 rem **************************
20 rem *** ***
30 rem *** JIGSAW 3 ***
40 rem *** ***
50 rem **************************
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 on error goto 2140
90 if drvmap=1 then drive$="A" : goto 170
100 if drvmap>1 then print "Select drive, or wait, 20 seconds!"
110 D$=""
120 repeat
130 D$=inkey$
140 inc TRP
150 until D$<>"" or TRP=25000
160 if D$="" then D$="A"
170 DRV=drive : drive$=D$ : dir$=D$+":\"
180 X1=63 : X2=319 : Y1=0 : Y2=199
190 X3=0 : X4=X1 : Y3=120 : Y4=Y2
200 JIGHRZ=5 : JIGVER=5 : JBUTS=9
210 JIG=25 : JSPRHT=39 : JSPRWD=48
220 JIGFST=4 : JIGLST=JIG+3 : MSPR=2 : JDSPR=4
230 JIGX1=X1+1 : JIGX2=JIGX1+JIGHRZ*JSPRWD
240 JIGY1=Y1+2 : JIGY2=JIGY1+JIGVER*JSPRHT
250 JIGX3=X3 : JIGX4=X4
260 JIGY3=Y3 : JIGY4=Y4
270 dim JX(JIG) dim JY(JIG)
280 dim SWP(JIG),SPR(JIG+1)
290 rem
300 rem ------ grab sprites & make jigsaw
310 rem
320 if length(1)<>0 then goto 410
330 erase 1
340 cls : locate 10,0 : print "LOAD A SPRITE BANK"
350 show on : SPR$=file select$("*.MBK")
360 F$=SPR$ : BNK=1 : gosub 700
370 rem
380 rem
390 rem ---- Load a picture
400 rem
410 if length(6)<>0 then goto 490
420 if length(6)=0 then reserve as screen 6
430 cls : locate 10,0 : print "LOAD PICTURE"
440 show on : SCR$=file select$("*.*")
450 F$=SCR$ : BNK=6 : gosub 700
460 rem
470 rem ---- Load a packed screen
480 rem
490 if length(7)<>0 then goto 560
500 if length(7)=0 then reserve as screen 7
510 cls : locate 10,0 : print "LOAD PACed FILE"
520 show on : PSCR$=file select$("*.pac")
530 F$=PSCR$ : BNK=8 : gosub 790
540 rem
550 rem
560 get palette (6)
570 screen copy 6 to back : screen copy 6 to physic
580 reduce 6 to 7,JIGX1,JIGY1,JIGX2,JIGY2
590 reduce 6 to 7,JIGX3,JIGY3,JIGX4,JIGY4
600 fade 5
610 fade 5,6
620 get palette (6)
630 screen copy 7 to back : screen copy 7 to physic
640 rem
650 wait 20 : gosub 1340 : goto 1490
660 rem
670 rem
680 rem ------ FILE LOADER
690 rem
700 hide on : cls : load F$,BNK
710 locate 10,10
720 print F$;" IS LOADED" : wait 50
730 cls : return 740 rem
750 rem ----- PACed FILE LOADER
760 rem
770 rem get size of file to unsquash
780 rem
790 hide on : cls
800 open in #1,F$ : LF=lof(#1) : close #1
810 erase BNK : reserve as work BNK,LF
820 bload F$,BNK
830 rem
840 rem unsquashing file in a screen bank
850 rem
860 copy start(8),start(8)+LF to start(7)
870 unsquash 7,LF
880 locate 10,10
890 print F$;" IS LOADED" : wait 50
900 cls : return 910 rem
920 rem --- Setting the Zones ---
930 rem
940 rem
950 reset zone : restore 2210
960 for F=1 to JBUTS
970 read A,B,C,D
980 set zone F,A,B to C,D
990 box A,B to C,D
1000 next F
1010 gosub 1340
1020 rem
1030 x mouse=11 : y mouse=11
1040 mouseon : show on
1050 MK=0
1060 repeat
1070 rem
1080 if x mouse<JIGX1 or x mouse>JIGX2-JSPRWD+2 or y mouse<JIGY1 or
y mouse>JIGY2-JSPRHT+2 then change mouse MSPR else change mouse JDSPR
1090 MK=mouse key
1100 until MK<>0
1110 ZN=zone(0)
1120 rem
1130 shoot : hide on : wait 10 : mouseoff
1140 rem
1150 rem --- Find Which Zone ---
1160 rem
1170 if ZN=0 then goto 1040
1180 if ZN>0 and ZN<=9 then goto 1190 else goto 1280
1190 if ZN=1 then JDSPR=JIGFST
1200 if ZN=2 then JDSPR=JIGLST
1210 if ZN=3 then inc JDSPR : gosub 2070
1220 if ZN=4 then dec JDSPR : gosub 2090
1230 if ZN=5 then goto 1040
1240 if ZN=6 then goto 1040
1250 if ZN=7 then goto 1040
1260 if ZN=8 then goto 1040
1270 if ZN=9 then default : mouseon : end
1280 if x mouse>JIGX1 and x mouse<JIGX2 and y mouse>JIGY1 and y
mouse<JIGY2 then goto 1990
1290 goto 1040
1300 rem
1310 rem
1320 rem *** draw jigsaw grid zones ***
1330 rem
1340 GX1=JIGX1 : GX2=JIGX2 : GY1=JIGY1 : GY2=JIGY2
1350 GX3=GX1+JSPRWD : GY3=GY1+JSPRHT
1360 for F=1 to JIG
1370 JX(F)=GX1 : JY(F)=GY1
1380 GX1=GX1+JSPRWD
1390 if GX1>=JSPRWD*JIGHRZ+JIGX1 then GX1=JIGX1 : GY1=GY1+JSPRHT
1400 next F
1410 for F=1 to JIG
1420 set zone F+JBUTS,JX(F),JY(F) to JX(F)+JSPRWD,JY(F)+JSPRHT
1430 box JX(F),JY(F) to JX(F)+JSPRWD,JY(F)+JSPRHT
1440 next F
1450 return 1460 rem
1470 rem --- Convert picture into sprites
1480 rem
1490 JX=JIGX1 : JY=JIGY1
1500 for F=1 to JIG
1510 get sprite JX,JY,F
1520 JX=JX+JSPRWD
1530 if JX>=JIGX2 then JX=X1+1 : JY=JY+JSPRHT
1540 next F
1550 rem
1560 rem ---- Mixing Sprites up ----
1570 rem
1580 for F=0 to JIG
1590 SPR(F)=F
1600 next F
1610 rem
1620 repeat 1630 NUM=rnd(JIG)+1
1640 if SWP(NU)=0 and SPR(NUM)<>0 then SWP(NU)=SPR(NUM) else goto
1630
1650 inc NU : SPR(NUM)=0
1660 until NU=JIG
1670 rem
1680 rem ---- display to screen ----
1690 rem
1700 DX=JIGX1 : DY=JIGY1
1710 cls physic,0,JIGX1,JIGY1+1 to JIGX2,JIGY2
1720 cls back,0,JIGX1,JIGY1+1 to JIGX2,JIGY2
1730 for F=1 to JIG
1740 sprite 1,DX,DY,SWP(F-1)
1750 wait vbl : put sprite 1
1760 DX=DX+JSPRWD
1770 if DX>=JIGX2 then DX=JIGX1 : DY=DY+JSPRHT
1780 rem
1790 next F
1800 rem
1810 rem --- Re-Convert picture into sprites ---
1820 rem
1830 JX=JIGX1 : JY=JIGY1
1840 for F=1 to JIG
1850 get sprite JX,JY,F
1860 JX=JX+JSPRWD
1870 if JX>=JIGX2 then JX=X1+1 : JY=JY+JSPRHT
1880 next F
1890 wait 75
1900 rem
1910 cls physic,0,JIGX1,JIGY1+1 to JIGX2,JIGY2
1920 cls back,0,JIGX1,JIGY1+1 to JIGX2,JIGY2
1930 sprite off
1940 goto 940
1950 rem
1960 rem
1970 rem +++ placing pieces in jigsaw +++
1980 rem
1990 DJP=ZN-9
2000 rem
2010 hide on : change mouse 2
2020 sprite 1,JX(DJP),JY(DJP),JDSPR-3
2030 wait vbl : put sprite 1
2040 x mouse=30 : y mouse=18
2050 goto 1040
2060 rem
2070 if JDSPR=1 then JDSPR=JIGFST+1
2080 if JDSPR>JIGLST then JDSPR=JIGFST
2090 if JDSPR=0 then JDSPR=JIGLST
2100 if JDSPR<JIGFST then JDSPR=JIGLST
2110 return 2120 rem ------ ERROR TRAPPING
2130 rem
2140 if errn=83 then D$="A" : goto 170
2150 default : mouseon 2160 if errn<>83 then cls : print "ERROR AT
LINE";errl : print "ERROR IS";errn
2170 print "Enter Command ERROR ERRN to get help"
2180 rem
2190 rem data for ZONES and JIGSAW
2200 rem
2210 data 0,0,32,18,32,0,63,18
2220 data 0,19,32,37,32,19,63,37
2230 data 0,38,32,66,32,38,63,66
2240 data 0,67,32,95,32,67,63,95
2250 data 0,96,63,119
2260 data 0,67,32,95,32,67,63,95
Gosh, I bet that you thought that it would go on for ever. Well
at least a third of it is rem statements. And most of the rest
has already been covered, so it is not so bad really - otherr
than the space that it is takeing up.
Lines:
10 rem **************************
20 rem *** ***
30 rem *** JIGSAW 3 ***
40 rem *** ***
50 rem **************************
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
Should be clear enough to you.
Line:
80 on error goto 2140
Tests for errors. IT is not intended to work all that well at the
moment. After all I am only testing a partial programme at the
moment, so it does not need to be that good.
Lines:
90 if drvmap=1 then drive$="A" : goto 170
100 if drvmap>1 then print "Select drive, or wait, 20 seconds!"
110 D$=""
120 repeat 130 D$=inkey$
140 inc TRP
150 until D$<>"" or TRP=25000
160 if D$="" then D$="A"
170 DRV=drive : drive$=D$ : dir$=D$+":\"
Are the new default drive bit. It does not work as I would like,
but it does what is intended. It alows you to press the key of
the drive to default to, or after 20 seconds it defaults to drive
A: on its own.
Lines:
180 X1=63 : X2=319 : Y1=0 : Y2=199
190 X3=0 : X4=X1 : Y3=120 : Y4=Y2
200 JIGHRZ=5 : JIGVER=5 : JBUTS=9
210 JIG=25 : JSPRHT=39 : JSPRWD=48
220 JIGFST=4 : JIGLST=JIG+3 : MSPR=2 : JDSPR=4
230 JIGX1=X1+1 : JIGX2=JIGX1+JIGHRZ*JSPRWD
240 JIGY1=Y1+2 : JIGY2=JIGY1+JIGVER*JSPRHT
250 JIGX3=X3 : JIGX4=X4
260 JIGY3=Y3 : JIGY4=Y4
270 dim JX(JIG) dim JY(JIG)
280 dim SWP(JIG),SPR(JIG+1)
Are variables used in the programme.
And that is As far as I can go in this tutorial, due to the above
mentioned problems.
290 rem
300 rem ------ grab sprites & make jigsaw
310 rem
320 if length(1)<>0 then goto 410
330 erase 1
340 cls : locate 10,0 : print "LOAD A SPRITE BANK"
350 show on : SPR$=file select$("*.MBK")
360 F$=SPR$ : BNK=1 : gosub 700
370 rem
380 rem
390 rem ---- Load a picture
400 rem
410 if length(6)<>0 then goto 490
420 if length(6)=0 then reserve as screen 6
430 cls : locate 10,0 : print "LOAD PICTURE"
440 show on : SCR$=file select$("*.*")
450 F$=SCR$ : BNK=6 : gosub 700
460 rem
470 rem ---- Load a packed screen
480 rem
490 if length(7)<>0 then goto 560
500 if length(7)=0 then reserve as screen 7
510 cls : locate 10,0 : print "LOAD PACed FILE"
520 show on : PSCR$=file select$("*.pac")
530 F$=PSCR$ : BNK=8 : gosub 790
540 rem
550 rem
560 get palette (6)
570 screen copy 6 to back : screen copy 6 to physic
580 reduce 6 to 7,JIGX1,JIGY1,JIGX2,JIGY2
590 reduce 6 to 7,JIGX3,JIGY3,JIGX4,JIGY4
600 fade 5
610 fade 5,6
620 get palette (6)
630 screen copy 7 to back : screen copy 7 to physic
640 rem
650 wait 20 : gosub 1340 : goto 1490
660 rem
670 rem
680 rem ------ FILE LOADER
690 rem
700 hide on : cls : load F$,BNK
710 locate 10,10
720 print F$;" IS LOADED" : wait 50
730 cls : return
740 rem
750 rem ----- PACed FILE LOADER
760 rem
770 rem get size of file to unsquash
780 rem
790 hide on : cls
800 open in #1,F$ : LF=lof(#1) : close #1
810 erase BNK : reserve as work BNK,LF
820 bload F$,BNK
830 rem
840 rem unsquashing file in a screen bank
850 rem
860 copy start(8),start(8)+LF to start(7)
870 unsquash 7,LF
880 locate 10,10
890 print F$;" IS LOADED" : wait 50
900 cls : return 910 rem
920 rem --- Setting the Zones ---
930 rem
940 rem
950 reset zone : restore 2210
960 for F=1 to JBUTS
970 read A,B,C,D
980 set zone F,A,B to C,D
990 box A,B to C,D
1000 next F
1010 gosub 1340
1020 rem
1030 x mouse=11 : y mouse=11
1040 mouseon : show on 1050 MK=0
1060 repeat
1070 rem
1080 if x mouse<JIGX1 or x mouse>JIGX2-JSPRWD+2 or y mouse<JIGY1 or
y mouse>JIGY2-JSPRHT+2 then change mouse MSPR else change mouse JDSPR
1090 MK=mouse key
1100 until MK<>0
1110 ZN=zone(0)
1120 rem
1130 shoot : hide on : wait 10 : mouseoff
1140 rem
1150 rem --- Find Which Zone ---
1160 rem
1170 if ZN=0 then goto 1040
1180 if ZN>0 and ZN<=9 then goto 1190 else goto 1280
1190 if ZN=1 then JDSPR=JIGFST
1200 if ZN=2 then JDSPR=JIGLST
1210 if ZN=3 then inc JDSPR : gosub 2070
1220 if ZN=4 then dec JDSPR : gosub 2090
1230 if ZN=5 then goto 1040
1240 if ZN=6 then goto 1040
1250 if ZN=7 then goto 1040
1260 if ZN=8 then goto 1040
1270 if ZN=9 then default : mouseon : end
1280 if x mouse>JIGX1 and x mouse<JIGX2 and y mouse>JIGY1 and y
mouse<JIGY2 then goto 1990
1290 goto 1040
1300 rem
1310 rem
1320 rem *** draw jigsaw grid zones ***
1330 rem
1340 GX1=JIGX1 : GX2=JIGX2 : GY1=JIGY1 : GY2=JIGY2
1350 GX3=GX1+JSPRWD : GY3=GY1+JSPRHT
1360 for F=1 to JIG
1370 JX(F)=GX1 : JY(F)=GY1
1380 GX1=GX1+JSPRWD
1390 if GX1>=JSPRWD*JIGHRZ+JIGX1 then GX1=JIGX1 : GY1=GY1+JSPRHT
1400 next F
1410 for F=1 to JIG
1420 set zone F+JBUTS,JX(F),JY(F) to JX(F)+JSPRWD,JY(F)+JSPRHT
1430 box JX(F),JY(F) to JX(F)+JSPRWD,JY(F)+JSPRHT
1440 next F
1450 return 1460 rem
1470 rem --- Convert picture into sprites
1480 rem
1490 JX=JIGX1 : JY=JIGY1
1500 for F=1 to JIG
1510 get sprite JX,JY,F
1520 JX=JX+JSPRWD
1530 if JX>=JIGX2 then JX=X1+1 : JY=JY+JSPRHT
1540 next F
1550 rem
1560 rem ---- Mixing Sprites up ----
1570 rem
1580 for F=0 to JIG
1590 SPR(F)=F
1600 next F
1610 rem
1620 repeat 1630 NUM=rnd(JIG)+1
1640 if SWP(NU)=0 and SPR(NUM)<>0 then SWP(NU)=SPR(NUM) else goto
1630
1650 inc NU : SPR(NUM)=0
1660 until NU=JIG
1670 rem
1680 rem ---- display to screen ----
1690 rem
1700 DX=JIGX1 : DY=JIGY1
1710 cls physic,0,JIGX1,JIGY1+1 to JIGX2,JIGY2
1720 cls back,0,JIGX1,JIGY1+1 to JIGX2,JIGY2
1730 for F=1 to JIG
1740 sprite 1,DX,DY,SWP(F-1)
1750 wait vbl : put sprite 1
1760 DX=DX+JSPRWD
1770 if DX>=JIGX2 then DX=JIGX1 : DY=DY+JSPRHT
1780 rem
1790 next F
1800 rem
1810 rem --- Re-Convert picture into sprites ---
1820 rem
1830 JX=JIGX1 : JY=JIGY1
1840 for F=1 to JIG
1850 get sprite JX,JY,F
1860 JX=JX+JSPRWD
1870 if JX>=JIGX2 then JX=X1+1 : JY=JY+JSPRHT
1880 next F
1890 wait 75
1900 rem
1910 cls physic,0,JIGX1,JIGY1+1 to JIGX2,JIGY2
1920 cls back,0,JIGX1,JIGY1+1 to JIGX2,JIGY2
1930 sprite off 1940 goto 940
1950 rem
1960 rem
1970 rem +++ placing pieces in jigsaw +++
1980 rem
1990 DJP=ZN-9
2000 rem
2010 hide on : change mouse 2
2020 sprite 1,JX(DJP),JY(DJP),JDSPR-3
2030 wait vbl : put sprite 1
2040 x mouse=30 : y mouse=18
2050 goto 1040
2060 rem
2070 if JDSPR=1 then JDSPR=JIGFST+1
2080 if JDSPR>JIGLST then JDSPR=JIGFST
2090 if JDSPR=0 then JDSPR=JIGLST
2100 if JDSPR<JIGFST then JDSPR=JIGLST
2110 return 2120 rem ------ ERROR TRAPPING
2130 rem
2140 if errn=83 then D$="A" : goto 170
2150 default : mouseon
2160 if errn<>83 then cls : print "ERROR AT LINE";errl : print
"ERROR IS";errn
2170 print "Enter Command ERROR ERRN to get help"
2180 rem
2190 rem data for ZONES and JIGSAW
2200 rem
2210 data 0,0,32,18,32,0,63,18
2220 data 0,19,32,37,32,19,63,37
2230 data 0,38,32,66,32,38,63,66
2240 data 0,67,32,95,32,67,63,95
2250 data 0,96,63,119
2260 data 0,67,32,95,32,67,63,95